# Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.

# CMake lowest version requirement
cmake_minimum_required(VERSION 3.5.1)

# project information
project(MindX_Sample)

# Compile options
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
add_definitions(-Dgoogle=mindxsdk_private)
add_compile_options(-std=c++11 -fPIC -fstack-protector-all -Wall)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY  "../../../out")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")

# Header path
include_directories(
    ${MX_SDK_HOME}/include/
    ${MX_SDK_HOME}/opensource/include/
    ${MX_SDK_HOME}/opensource/include/opencv4/
    ../include/
)

# add host lib path
link_directories(
    ${MX_SDK_HOME}/lib/
    ${MX_SDK_HOME}/opensource/lib/
    ${MX_SDK_HOME}/opensource/lib64/
    ${MX_SDK_HOME}/opensource/include/opencv4/
)

add_executable(main main.cpp)

target_link_libraries(main glog mxbase streammanager cpprest mindxsdk_protobuf opencv_world)

install(TARGETS main DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../config/logging.conf DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../out/config)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../config/sdk.conf DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../out/config)
